extends AnimationPlayer

var anim_list = []			#这个大子目前身上有这些状态

func _ready():
	pass

func update(arr_states:Array):
	var arr_copy = arr_states.duplicate(true)
	arr_copy.erase(BigStateType.HIDE)
	arr_copy.erase(BigStateType.ICE)
	arr_copy.erase(BigStateType.SHIELD)
	anim_list = arr_copy
	# 如果当前没有播放动画，启动起来
	if !is_playing() && anim_list.size() > 1:
		play(anim_list[0])
	
# 2个以上状态才会轮播
func playNext(anim_name:String):
	if (anim_list.size() == 0):
		stop()
	elif (anim_list.size() == 1):
		play("默认")
	else:
		var current_index = anim_list.find(anim_name)
		var next_index = (current_index + 1) % anim_list.size()
		var next_anim = anim_list[next_index]
		play(next_anim)

# 动画播放结束了，找下一个动画进行播放
func _on_animation_finished(anim_name):
	playNext(anim_name)
